home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QRZ! Ham Radio 6
/
QRZ Ham Radio Callsign Database - Volume 6.iso
/
mac
/
files
/
amiga
/
rhinosrc.lha
/
finger.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-12
|
2KB
|
76 lines
/* Internet finger client
* Copyright 1991 Phil Karn, KA9Q
*/
#include <stdio.h>
#include <string.h>
#include "global.h"
#include "mbuf.h"
#include "socket.h"
#include "session.h"
#include "proc.h"
#include "netuser.h"
#include "commands.h"
#include "tty.h"
int
dofinger(argc,argv,p)
int argc;
char *argv[];
void *p;
{
struct sockaddr_in sock;
char *cp;
int s,i;
int c;
struct session *sp;
FILE *network;
/* Allocate a session descriptor */
if((sp = newsession(argv[1],FINGER,1)) == NULLSESSION){
printf("Too many sessions\n");
keywait(NULLCHAR,1);
return 1;
}
sp->ttystate.echo = sp->ttystate.edit = 0;
sock.sin_family = AF_INET;
sock.sin_port = IPPORT_FINGER;
for(i=1;i<argc;i++){
cp = strchr(argv[i],'@');
if(cp == NULLCHAR){
printf("%s: local names not supported\n",argv[i]);
continue;
}
*cp++ = '\0';
printf("%s@%s -- ",argv[i],cp);
printf("Resolving %s... ",cp);
if((sock.sin_addr.s_addr = resolve(cp)) == 0){
printf("Host %s unknown\n",cp);
continue;
}
printf("trying %s",psocket((struct sockaddr *)&sock));
if((s = socket(AF_INET,SOCK_STREAM,0)) == -1){
printf("Can't create socket\n");
break;
}
if(connect(s,(char *)&sock,sizeof(sock)) == -1){
cp = sockerr(s);
printf(" -- Connect failed: %s\n",cp != NULLCHAR ? cp : "");
close_s(s);
continue;
}
printf("\n");
sp->network = network = fdopen(s,"r+t");
fprintf(network,"%s\n",argv[i]);
fflush(stdout);
while((c = getc(network)) != EOF)
putchar(c);
fclose(network);
sp->network = NULLFILE;
}
keywait(NULLCHAR,1);
freesession(sp);
return 0;
}